home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / program / heatmon.zip / LP.C next >
C/C++ Source or Header  |  1995-12-09  |  16KB  |  649 lines

  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <bios.h>
  5. #include "lp.h"
  6. int key;
  7. FILE *fp1,*fp2,*fp3,*fp4,*fp5,*fp6,*fp7,*fp8;
  8. struct tm *ptr;
  9. time_t p_start;
  10. char t_start[25],on_start[25],off_start[25];
  11. char f_stat[4];
  12. int  fm_on=0,fm_off=0,fmcalc1=0,fmcalc2=0;
  13. int  fo_used=0,fo_rem=0,focalc1=0,focalc2=0;
  14. char fo_alarm='n';
  15. int  fc_size=0;
  16. int  fc_preset=0;
  17. int  fpreset=0;
  18. int  on_hour=0,on_min=0,on_sec=0;
  19. int  off_hour=0,off_min=0,off_sec=0;
  20. int  calc_on=0,calc_off=0;
  21. time_t lt;
  22. float lfile_size=0;
  23. char  lfile_status='A';
  24. float lfile_max=850000;
  25. char alert_log='I',alert_fuel='I';
  26. int times_on=0,times_off=0;
  27. int x=0,y=0;
  28. char alert_notify='A';
  29. int oil_min=50;
  30. /* Fuel est: 45 gals = 14days                  */
  31. /* .0459 gal per hour                          */
  32. /*  .000765 gal per minute                     */
  33. /*  .0000128 gal per second                    */
  34. float oil_gps=0.0000128;
  35. float oil_rem=0,oil_used=0;
  36. main()
  37. {
  38.     unsigned status;
  39.     unsigned lpt_io();
  40.     unsigned int i;
  41.     p_start = time(NULL);
  42.     ptr = localtime(&p_start);
  43.     strcpy(t_start,asctime(ptr));
  44.     clrscr();
  45.     for(;;){
  46.      menu_loop();
  47.      }
  48. }
  49.  
  50. menu_loop()
  51. {
  52.      char ch;
  53.      char endkey;
  54.      clrscr();
  55.      gotoxy(1,1);
  56.      cprintf("       Home Heating System - ver: 1.00     \n");
  57.      gotoxy(1,2);
  58.      cprintf("*******************************************\n");
  59.      gotoxy(1,3);
  60.      cprintf("            MAIN MENU            \n");
  61.      gotoxy(1,4);
  62.      cprintf("-------------------------------------------\n");
  63.      gotoxy(1,5);
  64.      cprintf("MODE    Option Description                 \n");
  65.      gotoxy(1,6);
  66.      cprintf("------  ------ ----------------------------\n");
  67.      gotoxy(1,7);
  68.      cprintf("ONLINE     1    Start Monitoring System    \n");
  69.      gotoxy(1,8);
  70.      cprintf("ONLINE     2    Dump Monitor Data          \n");
  71.      gotoxy(1,9);
  72.      cprintf("ONLINE     3    Reset Monitor stats        \n");
  73.      gotoxy(1,10);
  74.      cprintf("ONLINE     4    Disable all alarms!        \n");
  75.      gotoxy(1,11);
  76.      cprintf("OFFLINE    5    Set Furn Status -> OFF     \n");
  77.      gotoxy(1,12);
  78.      cprintf("OFFLINE    6    Reset Fuel Status (FILL)   \n");
  79.      gotoxy(1,13);
  80.      cprintf("ONLINE     7    Toggle notify status alarm \n");
  81.      gotoxy(1,14);
  82.      cprintf("ONLINE     8    Recover statistics         \n");
  83.      gotoxy(1,15);
  84.      cprintf("ONLINE     9    Set Current Gallons of Oil \n");
  85.      gotoxy(1,16);
  86.      cprintf("ONLINE     X    Exit/End Monitoring System \n");
  87.      gotoxy(1,18);
  88.      cprintf("==========>\n");
  89.      gotoxy(13,18);
  90.  
  91.      getcode();
  92.      switch (key){
  93.        case 49:
  94.         clrscr();
  95.         strcpy(f_stat,"   ");
  96.         while(!bioskey(1)) furn_loop();
  97.         clrscr();
  98.         printf("Press Enter to Continue! \n");
  99.         getch();
  100.         break;
  101.        case 50:
  102.         clrscr();
  103.         printf("Processing Monitor data.\n");
  104.         printf("COPYING:Furndat====>Furnout\n");
  105.         fclose(fp1);
  106.         if((fp1=fopen("furndat","r")) == NULL){
  107.             printf("Cannot open data file \n\a");
  108.             getch();
  109.         }
  110.         if((fp2=fopen("A:furnout","wt")) == NULL){
  111.             printf("Cannot open output file \n\a");
  112.             getch();
  113.         }
  114.         while(!feof(fp1)){
  115.             ch = getc(fp1);
  116.             if(!feof(fp1))putc(ch,fp2);
  117.         }
  118.         printf("COPY COMPLETE\n");
  119.         lfile_size = 0;
  120.         lfile_status = 'A';
  121.         printf("closing files\n");
  122.         fclose(fp1);
  123.         fclose(fp2);
  124.         printf("erasing Furndat \n");
  125.         remove("furndat");
  126.         printf("Capture log stats --> reset\n");
  127.         alert_log='I';
  128.         printf("Processing is Complete!\n");
  129.         printf("Reopening Furndat data file \n");
  130.         if((fp1=fopen("Furndat","a")) == NULL){
  131.             printf("Cannot open Furndat file \n\a");
  132.             getch();
  133.         }
  134.         printf("Press Enter to continue\n\a\a\a");
  135.         getch();
  136.         break;
  137.        case 51:
  138.         clrscr();
  139.         printf("Resetting Monitor Stats\n");
  140.         printf("Logged on Minutes    => RESET\n");
  141.         on_hour=0;
  142.         on_min=0;
  143.         on_sec=0;
  144.         printf("Logged off Minutes   => RESET\n");
  145.         off_hour=0;
  146.         off_min=0;
  147.         off_sec=0;
  148.         printf("Initiate date/time   => RESET\n");
  149.         printf("Fuel used            => RESET\n");
  150.         printf("Fuel remaining       => RESET\n");
  151.         printf("Furnace status       => RESET\n");
  152.         times_on=0;
  153.         times_off=0;
  154.         printf("Processing Complete!\n");
  155.         printf("Press Enter to continue\n");
  156.         getch();
  157.         break;
  158.        case 52:
  159.         clrscr();
  160.         printf("Disabling all alarms!\n");
  161.         alert_log='I';
  162.         alert_fuel='I';
  163.         printf("complete\n");
  164.         printf("press Enter to continue\n");
  165.         getch();
  166.         break;
  167.        case 53:
  168.         clrscr();
  169.         printf("Setting Furnace status to =>OFF<=\n");
  170.         printf("press Enter to continue\n");
  171.         getch();
  172.         break;
  173.        case 54:
  174.         clrscr();
  175.         printf("Reset Fuel statistics - (OIL Fill up)\n");
  176.         oil_rem = 180;
  177.         oil_used = 0;
  178.         printf("Fuel Stats ==> RESET\n");
  179.         printf("Press Enter to continue\n");
  180.         getch();
  181.         break;
  182.        case 55:
  183.         clrscr();
  184.         printf("Toggle notify status alarm\n");
  185.         if(alert_notify == 'A'){
  186.             alert_notify='I';
  187.             }
  188.         if(alert_notify == 'I'){
  189.             alert_notify='A';
  190.             }
  191.         printf("Done.\n");
  192.         getch();
  193.         break;
  194.        case 56:
  195.         clrscr();
  196.         printf("Recover statistics from disk..\n");
  197.         printf("processing.. time on\n");
  198.            if((fp4=fopen("minon","rt")) == NULL){
  199.             cprintf("Cannot open data file \n\a");
  200.            }
  201.            fscanf(fp4,"%i%i%i",&on_hour,&on_min,&on_sec);
  202.            fclose(fp4);
  203.         printf("processing.. time off\n");
  204.            if((fp6=fopen("minoff","rt")) == NULL){
  205.             cprintf("Cannot open data file \n\a");
  206.            }
  207.            fscanf(fp6,"%i%i%i",&off_hour,&off_min,&off_sec);
  208.            fclose(fp6);
  209.         printf("processing.. # times on\n");
  210.            if((fp3=fopen("timeon","rt")) == NULL){
  211.             cprintf("Cannot open data file \n\a");
  212.            }
  213.            fscanf(fp3,"%i",×_on);
  214.            fclose(fp3);
  215.         printf("processing.. # times off\n");
  216.            if((fp5=fopen("timeoff","rt")) == NULL){
  217.             cprintf("Cannot open data file \n\a");
  218.            }
  219.            fscanf(fp5,"%i",×_off);
  220.            fclose(fp5);
  221.         printf("Done.\n");
  222.         getch();
  223.         break;
  224.        case 57:
  225.         clrscr();
  226.         printf("Please enter the current amount of \n");
  227.         printf("gallons in the oil tank.           \n");
  228.         scanf("%f",&oil_rem);
  229.         printf("Done.");
  230.         getch();
  231.         break;
  232.        case 88:
  233.         clrscr();
  234.         printf("Exit Monitoring System \n");
  235.         printf("Are you sure??  y or n \n");
  236.         endkey=getche();
  237.         if(endkey=='y'){
  238.             exit(0);
  239.                  }
  240.                  else{
  241.             printf("\n");
  242.             printf("Exit aborted\n");
  243.             printf("Press enter to continue\n");
  244.             getch();
  245.             break;
  246.                  }
  247.        case 120:
  248.         clrscr();
  249.         printf("Exit Monitoring System \n");
  250.         printf("Are you sure??  y or n \n");
  251.         endkey=getche();
  252.         if(endkey=='y'){
  253.             exit(0);
  254.                  }
  255.                  else{
  256.             printf("\n");
  257.             printf("Exit aborted\n");
  258.             printf("Press enter to continue\n");
  259.             getch();
  260.             break;
  261.                  }
  262.        default:
  263.         clrscr();
  264.         printf("This key is not defined to the system??\n");
  265.         printf("Press enter to continue\n");
  266.         getch();
  267.         }
  268. }
  269.  
  270. int getcode(void)
  271. {
  272.     if(key=getch()){
  273.         return key;
  274.         }
  275.         else{
  276.         return(getch());
  277.         }
  278. }
  279.  
  280. furn_loop()
  281. {
  282.     unsigned status;
  283.     unsigned lpt_io();
  284.     unsigned int i;
  285.     char recid;
  286.     char p[]="*";
  287.     time_t lt,start_time, end_time;
  288.     gotoxy(15,1);
  289.     cprintf("  Home Heating Monitor - ver 1.00  \n");
  290.     gotoxy(15,2);
  291.     cprintf("  Program date: 11/28/95           \n");
  292.     gotoxy(15,3);
  293.     cprintf("-----------------------------------\n");
  294.     gotoxy(15,4);
  295.     printf("Initiated:");
  296.     printf("%s",t_start);
  297.     printf("\n");
  298.     gotoxy(15,5);
  299.     cprintf("Current heat status => %s \n",f_stat);
  300.     gotoxy(15,6);
  301.     cprintf("Logged on  minutes  => %4i:%2i:%2i \n",on_hour,on_min,on_sec);
  302.     gotoxy(15,7);
  303.     printf("On>%s",on_start);
  304.     gotoxy(15,8);
  305.     cprintf("Logged off minutes  => %4i:%2i:%2i \n",off_hour,off_min,off_sec);
  306.     gotoxy(15,9);
  307.     cprintf("Off>%s",off_start);
  308.     gotoxy(15,10);
  309.     cprintf("Data Capture status => %c                            ",lfile_status);
  310.     gotoxy(15,11);
  311.     cprintf("Data File size      => %f\n",lfile_size);
  312.     gotoxy(15,12);
  313.     cprintf("Abort capture at    => %f\n",lfile_max);
  314.     gotoxy(15,13);
  315.     cprintf("Calculated fuel used=> %f\n",oil_used);
  316.     gotoxy(15,14);
  317.     cprintf("Calculated fuel rem => %f\n",oil_rem);
  318.     gotoxy(15,15);
  319.     cprintf("Preset alarm gals   => %i\n",oil_min);
  320.     gotoxy(15,16);
  321.     fuel_graph();
  322.     gotoxy(15,17);
  323.     cprintf("           (Monitor status)        \n");
  324.     gotoxy(15,18);
  325.     status = lpt_io(LPT1, 0, INIT);
  326.     cprintf(" Port               => %u\n",status);
  327.     gotoxy(15,19);
  328.     cprintf("Times on=>%i Times off=>%i\n",times_on,times_off);
  329.     switch(status){
  330.        case 16:
  331.          lt=time(NULL);
  332.          gotoxy(15,20);
  333.          if(on_sec > 60){
  334.         on_min = on_min + 1;
  335.         on_sec = 0;
  336.          }
  337.          if(on_min > 60){
  338.         on_hour = on_hour + 1;
  339.         on_min = 0;
  340.          }
  341.  
  342.          cprintf("FURNACE IS ON  \n");
  343.          if(!stricmp(f_stat," ON")){
  344.         on_sec = on_sec + 1;
  345.         /* on time calc  */
  346.          }
  347.          else{
  348.         on_sec = on_sec + 1;
  349.         if(on_sec > 60){
  350.            on_min = on_min + 1;
  351.            on_sec = 0;
  352.         }
  353.         if(on_min > 60){
  354.            on_hour = on_hour + 1;
  355.            on_min = 0;
  356.         }
  357.         if((fp3=fopen("timeon","wt")) == NULL){
  358.             cprintf("Cannot open data file \n\a");
  359.         }
  360.         fprintf(fp3,"%i",times_on);
  361.         fclose(fp3);
  362.         if((fp4=fopen("minon","wt")) == NULL){
  363.             cprintf("Cannot open data file \n\a");
  364.         }
  365.         fprintf(fp4,"%i%i%i",on_hour,on_min,on_sec);
  366.         fclose(fp4);
  367.         oil_used = oil_used + oil_gps;
  368.         oil_rem = oil_rem - oil_gps;
  369.         if((fp7=fopen("oiluse","wt")) == NULL){
  370.             cprintf("Cannot open data file \n\a");
  371.         }
  372.         fprintf(fp7,"%f",oil_used);
  373.         fclose(fp7);
  374.         if((fp8=fopen("oilrem","wt")) == NULL){
  375.             cprintf("Cannot open data file \n\a");
  376.         }
  377.         fprintf(fp8,"%f",oil_rem);
  378.         fclose(fp8);
  379.         if(on_sec > 60){
  380.            on_min = on_min + 1;
  381.            on_sec = 0;
  382.         }
  383.         if(on_min > 60){
  384.            on_hour = on_hour + 1;
  385.            on_min = 0;
  386.         }
  387.         if(alert_notify == 'A'){
  388.            printf("\a");
  389.         }
  390.         strcpy(f_stat," ON");
  391.         for(x=1;x<26;x++){
  392.             on_start[x]=' ';
  393.         }
  394.         strcpy(on_start,asctime(ptr));
  395.         times_on=times_on+1;
  396.         recid='A';
  397.         if(lfile_size > lfile_max){
  398.            lfile_status = 'I';
  399.            alert_log='A';
  400.         }
  401.         if(lfile_status=='A'){
  402.            if((fp1=fopen("furndat","a")) == NULL){
  403.                cprintf("Cannot open data file \n\a");
  404.            }
  405.         fprintf(fp1,"%c%s%i%i%i",recid,ctime(<),on_hour,on_min,on_sec);
  406.         lfile_size=lfile_size+27;
  407.         fclose(fp1);
  408.         }
  409.          }
  410.          if(on_sec > 60){
  411.         on_min = on_min + 1;
  412.         on_sec = 0;
  413.          }
  414.          if(on_min > 60){
  415.         on_hour = on_hour + 1;
  416.         on_min = 0;
  417.          }
  418.          biosprint(0,*p,1);
  419.          break;
  420.        default:
  421.          lt=time(NULL);
  422.          gotoxy(15,20);
  423.          if(off_sec > 60){
  424.         off_min = off_min + 1;
  425.         off_sec = 0;
  426.          }
  427.          if(off_min > 60){
  428.         off_hour = off_hour + 1;
  429.         off_min = 0;
  430.          }
  431.          cprintf("FURNACE IS OFF  \n");
  432.          if(!stricmp(f_stat,"OFF")){
  433.         /* off calc */
  434.         off_sec = off_sec + 1;
  435.          }
  436.          else{
  437.         if(off_sec > 60){
  438.            off_min = off_min + 1;
  439.            off_sec = 0;
  440.         }
  441.         if(off_min > 60){
  442.            off_hour = off_hour + 1;
  443.            off_min = 0;
  444.         }
  445.         if((fp5=fopen("timeoff","wt")) == NULL){
  446.             cprintf("Cannot open data file \n\a");
  447.         }
  448.         fprintf(fp5,"%i",times_off);
  449.         fclose(fp5);
  450.         if((fp6=fopen("minoff","wt")) == NULL){
  451.             cprintf("Cannot open data file \n\a");
  452.         }
  453.         fprintf(fp6,"%i%i%i",off_hour,off_min,off_sec);
  454.         fclose(fp6);
  455.         off_sec = off_sec  + 1;
  456.         if(off_sec > 60){
  457.            off_min = off_min + 1;
  458.            off_sec = 0;
  459.         }
  460.         if(off_min > 60){
  461.            off_hour = off_hour + 1;
  462.            off_min = 0;
  463.         }
  464.         if(alert_notify=='A'){
  465.            printf("\a");
  466.         }
  467.         strcpy(f_stat,"OFF");
  468.         for(x=1;x<26;x++){
  469.             off_start[x]=' ';
  470.         }
  471.         strcpy(off_start,asctime(ptr));
  472.         times_off=times_off+1;
  473.         recid='I';
  474.         if(lfile_size > lfile_max){
  475.            lfile_status = 'I';
  476.            alert_log='A';
  477.         }
  478.         if(lfile_status=='A'){
  479.            if((fp1=fopen("furndat","a")) == NULL){
  480.                cprintf("Cannot open data file \n\a");
  481.            }
  482.            fprintf(fp1,"%c%s%i%i%i",recid,ctime(<),off_hour,off_min,off_sec);
  483.            lfile_size=lfile_size+27;
  484.            fclose(fp1);
  485.         }
  486.          }
  487.          if(off_sec > 60){
  488.         off_min = off_min + 1;
  489.         off_sec = 0;
  490.          }
  491.          if(off_min > 60){
  492.         off_hour = off_hour + 1;
  493.         off_min = 0;
  494.          }
  495.  
  496.          break;
  497.     }
  498.     gotoxy(15,21);
  499.     cprintf("===================================\n");
  500.     sleep(1);
  501.     lt=time(NULL);
  502.     gotoxy(15,22);
  503.     cprintf(ctime(<));
  504.     gotoxy(15,23);
  505.     cprintf("       (Press any key to exit)     \n");
  506. }
  507.  
  508. alarms()
  509. {
  510.     if(alert_log=='A'){
  511.         clrscr();
  512.         printf("DATA FILE: size has reached maximum!\n");
  513.         printf("Please Dump!! \a");
  514.     }
  515.     if(alert_fuel=='A'){
  516.         clrscr();
  517.         printf("<<<<<<<<<< FUEL DANGER >>>>>>>>>>>\n\a\a");
  518.         printf("FUEL is less than 50gal \a\a DANGER!!! \a\a \n");
  519.     }
  520. }
  521.  
  522. fuel_graph()
  523. {
  524.     if(oil_rem > 179){
  525.         cprintf("  EMPTY<****+*****|*****+****>FULL \n");
  526.         }
  527.     if(oil_rem < 179 && oil_rem > 175){
  528.         cprintf("  EMPTY<****+*****|*****+***->FULL \n");
  529.         }
  530.     if(oil_rem < 175 && oil_rem > 170){
  531.         cprintf("  EMPTY<****+*****|*****+**-->FULL \n");
  532.         }
  533.     if(oil_rem < 170 && oil_rem > 161){
  534.         cprintf("  EMPTY<****+*****|*****+*--->FULL \n");
  535.         }
  536.     if(oil_rem < 161 && oil_rem > 153){
  537.         cprintf("  EMPTY<****+*****|******---->FULL \n");
  538.         }
  539.     if(oil_rem < 153 && oil_rem > 144){
  540.         cprintf("  EMPTY<****+*****|*****+---->FULL \n");
  541.         }
  542.     if(oil_rem < 144 && oil_rem > 136){
  543.         cprintf("  EMPTY<****+*****|****-+---->FULL \n");
  544.         }
  545.     if(oil_rem < 136 && oil_rem > 127){
  546.         cprintf("  EMPTY<****+*****|***--+---->FULL \n");
  547.         }
  548.     if(oil_rem < 127 && oil_rem > 119){
  549.         cprintf("  EMPTY<****+*****|**---+---->FULL \n");
  550.         }
  551.     if(oil_rem < 119 && oil_rem > 110){
  552.         cprintf("  EMPTY<****+*****|*----+---->FULL \n");
  553.         }
  554.     if(oil_rem < 110 && oil_rem > 102){
  555.         cprintf("  EMPTY<****+******-----+---->FULL \n");
  556.         }
  557.     if(oil_rem < 102 && oil_rem > 93){
  558.         cprintf("  EMPTY<****+*****|-----+---->FULL \n");
  559.         }
  560.     if(oil_rem < 93 && oil_rem > 85){
  561.         cprintf("  EMPTY<****+****-|-----+---->FULL \n");
  562.         }
  563.     if(oil_rem < 85 && oil_rem > 76){
  564.         cprintf("  EMPTY<****+***--|-----+---->FULL \n");
  565.         }
  566.     if(oil_rem < 76 && oil_rem > 68){
  567.         cprintf("  EMPTY<****+**---|-----+---->FULL \n");
  568.         }
  569.     if(oil_rem < 68 && oil_rem > 59){
  570.         cprintf("  EMPTY<****+*----|-----+---->FULL \n");
  571.         }
  572.     if(oil_rem < 59 && oil_rem > 51){
  573.         cprintf("  EMPTY<*****-----|-----+---->FULL \n");
  574.         }
  575.     if(oil_rem < 51 && oil_rem > 42){
  576.         cprintf("  EMPTY<****+-----|-----+---->FULL \n");
  577.         alert_fuel = 'A';
  578.         }
  579.     if(oil_rem < 42 && oil_rem > 34){
  580.         cprintf("  EMPTY<***-+-----|-----+---->FULL \n");
  581.         alert_fuel = 'A';
  582.         }
  583.     if(oil_rem < 34 && oil_rem > 25){
  584.         cprintf("  EMPTY<**--+-----|-----+---->FULL \n");
  585.         alert_fuel = 'A';
  586.         }
  587.     if(oil_rem < 25 && oil_rem > 17){
  588.         cprintf("  EMPTY<*---+-----|-----+---->FULL \n");
  589.         alert_fuel = 'A';
  590.         }
  591.     if(oil_rem < 17){
  592.         cprintf("  EMPTY<----+-----|-----+---->FULL \n");
  593.         alert_fuel = 'A';
  594.         }
  595. }
  596.  
  597. unsigned int
  598. lpt_io(port,byte,mode)
  599.     unsigned port;
  600.     unsigned byte;
  601.     int mode;
  602. {
  603.     unsigned i,j,status;
  604.     long unsigned otime;
  605.     switch (mode) {
  606.     case OUT:
  607.         outportb(port,byte);
  608.         outportb(port+2, 0x0d);
  609.         outportb(port+2, 0x0d);
  610.         outportb(port+2, 0x0c);
  611.         inportb(port+1);
  612.         status = (inportb(port+1) & 0x00f8) ^ 0x48;
  613.         return(status);
  614.     case  IN:
  615.         return(inportb(port));
  616.     case IS_BUSY:
  617.         return ( (inportb(port+1) & 0x80) ^ 0x80 );
  618.     case IS_ACK:
  619.         return ( inportb(port+1) & 0x60 );
  620.         switch (byte) {
  621.         case ASSERT:
  622.             i = inportb(port+2);
  623.             outportb(port+2, i | 0x8);
  624.             return ( (inportb(port+1) & 0xf8) ^ 0x48 );
  625.         case DEASSERT:
  626.             i = inportb(port+2);
  627.             outportb(port+2, i & ~0x8);
  628.             return ( (inportb(port+1) & 0xf8) ^ 0x48 );
  629.         default:
  630.             return(~0);
  631.         }
  632.     case INIT:
  633.         otime = biostime(0,0L);
  634.         outport(port+2, 0x08);
  635.         while ( otime + 1 > biostime(0,0L)) ;
  636.         outportb(port+2, 0x0c);
  637.     case STAT:
  638.         return( ((inportb(port+1) & 0xf8) ^ 0x48) );
  639.     case IS_PRESENT:
  640.     outportb(port,0x55);
  641.         if (inportb(port) == 0x55) {
  642.             return(~0);
  643.         }
  644.         return(0);
  645.     default:
  646.         return(~0);
  647.     }
  648. }
  649.